package com.gzhu.knowledgeAdmin.service.impl;


import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gzhu.knowledgeAdmin.dao.UserRoleMapper;
import com.gzhu.knowledgeAdmin.entity.UserRole;
import com.gzhu.knowledgeAdmin.service.UserRoleService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author testjava
 * @since 2020-01-12
 */
@Service
public class UserRoleServiceImpl extends ServiceImpl<UserRoleMapper, UserRole> implements UserRoleService {

    @Override
    public void deleteByUserIds(List<Integer> ids) {
        baseMapper.delete(new UpdateWrapper<UserRole>().in("user_id",ids));
    }

    @Override
    public void removeByRoleId(String id) {
        baseMapper.delete(new UpdateWrapper<UserRole>().eq("role_id",id));
    }

    @Override
    public void removeBatchByRoleIds(List<String> idList) {
        baseMapper.delete(new UpdateWrapper<UserRole>().in("role_id",idList));
    }

    @Override
    public String getRoleNameByUserId(Integer userId) {

        return baseMapper.getRoleNameByUserId(userId);

    }
}
